﻿namespace CommonUtilityInfrastructure.Tests
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using CommonUtilityInfrastructure;
    using NUnit.Framework;
    using SoftwareApproach.TestingExtensions;
    using UsefulTools.CheckboxedTree;
    using UsefulTools.ExtensionMethods;
    using Switch = UsefulTools.Switches.Switch;

    [TestFixture]
    public class TreeTests
    {
        

        [Test, ExpectedException(typeof(InvalidOperationException))]
        public void Tree_does_not_allow_adding_self_as_child()
        {
            var a = new CheckedNode("a");
            var ab = new CheckedNode("ab");

            ab.Parent = a;

            a.Children.Add(a);

        }
        [Test]
        public void Tree_allows_valid_child_and_parent()
        {
  
            var a = new CheckedNode("a");
            var ab = new CheckedNode("ab");

            ab.Parent = a;

            a.Children.Add(ab);

            Assert.Pass();
        }
        [Test,ExpectedException(typeof(InvalidOperationException))]
        public void Tree_does_not_allow_incomplete_settings()
        {
            var o = new CheckedNode("o");
            var a = new CheckedNode("a");
            var ab = new CheckedNode("ab");

            ab.Parent = a;

            o.Children.Add(a);
           
        }

        [Test, ExpectedException(typeof(InvalidOperationException))]
        public void Tree_does_not_allow_setting_parent_too_late()
        {
            var o = new CheckedNode("o");
            var a = new CheckedNode("a");
            var ab = new CheckedNode("ab");

            o.Children.Add(a);

            ab.Parent = a;
        }

        [Test, ExpectedException(typeof(InvalidOperationException))]
        public void Tree_does_not_allow_setting_parent_to_self()
        {
            var ab = new CheckedNode("ab");

            ab.Parent = ab;
        }

      
    }
}

